package com.epoint.spring.annotation;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.LinkedList;

public class Demo {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> aClass = Class.forName("com.epoint.spring.annotation.InitUser");

        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            boolean annotationPresent = method.isAnnotationPresent(InitAnnotation.class);
            if(annotationPresent){
                Constructor<?> constructor = aClass.getConstructor(null);
                method.invoke(constructor.newInstance(null), null);
            }

        }
    }

}
